﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Interface_Tier;
using Transfer_Object_Tier;

namespace eSolution_HRMSS.Winforms.QuaTrinhLamViec
{
    public partial class FR_KhenThuong : DevExpress.XtraEditors.XtraForm
    {
        IHRM_PROCESS_REWARDData _IHRM_PROCESS_REWARDData;
        ICommonCode _icommon;
        eSolution_HRMSS.HRMSS_Ultil util = new HRMSS_Ultil();
        Guid currentId;
        Guid new_id;
        bool isUpdate = false;
         public FR_KhenThuong(bool _isUpdate)
        {
            InitializeComponent();
            isUpdate = _isUpdate;
        }

         public FR_KhenThuong(bool _isUpdate, Guid _currentId)
        {
            InitializeComponent();
            isUpdate = _isUpdate;
            currentId = _currentId;
        }

        private void memoEdit2_EditValueChanged(object sender, EventArgs e)
        {

        }

        private void FR_KhenThuong_Load(object sender, EventArgs e)
        {
            _IHRM_PROCESS_REWARDData = (IHRM_PROCESS_REWARDData)Activator.GetObject(typeof(IHRM_PROCESS_REWARDData), util.ChuoiPROCESS_REWARDData);
            _icommon = (ICommonCode)Activator.GetObject(typeof(ICommonCode), util.Chuoicommon);
        }
        private HRM_PROCESS_REWARD lay_thong_tin()
        {
            string cancukhenthuong = txtcancukhenthuong.Text;
            string lidokhenthuong = txtlydokhenthuong.Text;
            string hinhthuckhenthuong = txthinhthuckhenthuong.Text;
            string soquyetdinh = txtsoquyetdinh.Text;
            string nguoibanhanh = txtnguoibanhanh.Text;
            DateTime ngaybanhanh = dtngaybanhanh.DateTime;
            HRM_PROCESS_REWARD reward = new HRM_PROCESS_REWARD();
            reward.Date = ngaybanhanh;
            reward.DecideNumber = soquyetdinh;
            reward.Foundation = cancukhenthuong;
            reward.Reason = lidokhenthuong;
            reward.Form = hinhthuckhenthuong;
            reward.Person=nguoibanhanh;
            return reward;
        }
        private void load_info()
        {
            DataTable dt = _IHRM_PROCESS_REWARDData.HRM_PROCESS_REWARD_Get(currentId).Tables[0];
            foreach (DataRow dr in dt.Rows)
            {
                txtcancukhenthuong.Text = dr["Foundation"].ToString();
                txtlydokhenthuong.Text = dr["Reason"].ToString();
                txthinhthuckhenthuong.Text = dr["Form"].ToString();
                txtsoquyetdinh.Text = dr["DecideNumber"].ToString();
                txtnguoibanhanh.Text = dr["Person"].ToString();
                dtngaybanhanh.DateTime = DateTime.Parse(dr["Date"].ToString());
            }
        }
    }
}